package com.mzz.structure.composite;

/**
 * @author xushijian
 * @date 18/6/8 上午9:16
 */
public class Test {

    public static void main(String[] args) {

        Component component = new Composite("根节点");

        Component child = new Composite("一级子节点child");

        Component child_child_1 = new Composite("一级子节点的子节点1");

        Component child_child_2 = new Composite("一级子节点的子节点2");

        child.add(child_child_1);
        child.add(child_child_2);

        Component child2 = new Composite("一级子节点child2");
        component.add(child);
        component.add(child2);

        component.foreach();

    }
}
